/**
 * 
 */
package org.softTank.BC.entity.services;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.softTank.BC.entity.IdEntity;

/**
 * @author Yuzone
 *
 */
@Entity
@Table(name = "SSDB_PARTNERLINKTYPE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class PartnerLinkType extends IdEntity {

	private String name;
	private String namespace;
	private String location;
	private String description;
	private Category category;
	private List<Role> roleList;

	@Column(nullable = false)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(nullable = false)
	public String getNamespace() {
		return namespace;
	}

	public void setNamespace(String namespace) {
		this.namespace = namespace;
	}

	@Column(nullable = false)
	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	@Column
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@ManyToOne(cascade = CascadeType.PERSIST)
	@JoinTable(name = "SSDB_CATEGORY_PARTNERLINKTYPE", joinColumns = { @JoinColumn(name = "PARTNERLINKTYPE_ID") }, inverseJoinColumns = { @JoinColumn(name = "CATEGORY_ID") })
	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	@OneToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
	@JoinTable(name = "SSDB_PARTNERLINKTYPE_ROLE", joinColumns = { @JoinColumn(name = "PARTNERLINKTYPE_ID") }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID") })
	@OrderBy("id")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<Role> getRoleList() {
		return roleList;
	}

	public void setRoleList(List<Role> roleList) {
		this.roleList = roleList;
	}

}
